home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3239 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.2 KB

  1. Path: crchh327.rich.bnr.ca!news
  2. From: Mike Hall <arnab@bnr.ca>
  3. Newsgroups: comp.lang.c++
  4. Subject: usage of ostrstream
  5. Date: 22 Jan 1996 23:50:58 GMT
  6. Organization: Bell Northern Research
  7. Message-ID: <4e17t2$24v@crchh327.rich.bnr.ca>
  8. NNTP-Posting-Host: crchhe1d.rich.bnr.ca
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 1.1 (X11; I; HP-UX A.09.05 9000/712)
  13. X-URL: news:comp.lang.c++
  14.  
  15. Hi,
  16. This is beginers query but any help is highly appreciated.
  17. I am working on C++ in HP-UX environment.
  18. I am trying to something like this in my code
  19. f()
  20. {
  21.  ostrstream oss;
  22.  
  23.  oss<<"The first string"<<ends
  24.  cout << oss.str()<<endl;
  25.  
  26.  oss.seekp(0);
  27.  oss<<"The second string in the same oss"<<ends;
  28.  cout << oss.str()<<endl;
  29. }
  30.  
  31. My test tool shows that the above has memory leaks.
  32. On reading the man pages I found that once .str() is
  33. called the buffer freezes and further usage of the oss
  34. object is unpredictable.Also the user should delete the
  35. char * returned by the .str().
  36.  
  37. What I'd like to know is, a way to use/access the  ostrstream
  38. string  multiply in a function without having to create a 
  39. ostrstream type object everytime.
  40.  
  41. Please E-Mail to arnab@bnr.ca
  42.  
  43. Thanks in advance for your help/suggestions
  44. Arnab
  45.  
  46.